import * as types from "../types/bindMobileTypes";

const initialState = {
  loading: false,
  error: undefined,
  code: "",
  countDownNum: "（59）",
};

export default function bindMobileReducer(state = initialState, action) {
  switch (action.type) {
    case types.BINDMOBILE_LOADING:
      return {
        ...state,
        loading: true,
      };
    case types.BINDMOBILE_DONE:
      return {
        ...state,
        loading: false,
      };
    case types.BINDMOBILE_ERROR:
      return {
        ...state,
        loading: false,
        error: action.error,
      };
    case types.BINDMOBILE_INPUTCODE:
      return {
        ...state,
        code: action.code,
      };
    case types.BINDMOBILE_COUNTDOWN:
      return {
        ...state,
        countDownNum: action.countDownNum,
      };
    case types.BINDMOBILE_REGETCODE:
      return {
        ...state,
        countDownNum: "",
      };
    case types.BINDMOBILE_UNMOUNT:
      return {
        ...initialState,
      };
    default:
      return state;
  }
}
